import { AxiosRequestConfig, AxiosResponse } from "axios";
import { Interceptors } from "./request";
export class HttpServer {
  axios: any;

  constructor() {
    this.axios = new Interceptors().getInterceptors();
  }

  request<T = any>(config: AxiosRequestConfig): Promise<T> {
    return new Promise((resolve, reject) => {
      this.axios(config)
        .then((res: AxiosResponse<T>) => {
          resolve(res as any);
        })
        .catch((err: any) => {
          reject(err);
        });
    });
  }
}

const http = new HttpServer();
export const host = import.meta.env.VITE_BASEURL;
export default http;
